<?php
Yii::app()->clientScript->registerScript('sel_status', "$('#selStatus').change(function(){console.log($(this).serialize()); $.fn.yiiGridView.update('carta-nutricional-grid',{data: $(this).serialize()}); return false;});");

$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => Yii::t('AweCrud.app', 'Lista de ') . CartaNutricional::label(2),
));
?>
<div class="row-fluid">
    <div class="span5" id="list-edades">
        <?php
        echo CHtml::activeLabel($submodel, 'edad', array('class' => 'span4'));
        $data = array('empty' => '- Seleccione -') + CHtml::listData(Edades::model()->findAll(), 'id', Edades::model()->representingColumn());
        $select = key($data);
        echo CHtml::dropDownList('dropDownStatus', $select, $data, array('style' => 'margin-botton:10px',
            'id' => 'selStatus', 'class' => 'span8')
        );
        ?>  
    </div>
    <div class="span5">
        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'type' => 'info',
            'icon' => 'icon-th-cancel',
            'label' => Yii::t('AweCrud.app', 'Resetear menú semanal'),
            'htmlOptions' => array('onclick' => 'js:accionResetear()'),
        ));
        ?>
    </div>

</div>
<div class="row-fluid">
    <br>
    <div style="overflow:scroll; height: 228px">
        <?php
        $this->widget('ext.selgridview.BootSelGridView', array(
            'id' => 'carta-nutricional-grid',
            'type' => 'striped condensed',
            'template' => '{items}{summary}{pager}',
            'dataProvider' => $submodel->searchGridView($select),
            'filter' => $submodel,
            'columns' => array(
                array(
                    'name' => 'id_cartaNutricional',
                    'id' => 'check',
                    'class' => 'CCheckBoxColumn',
                    'value' => '$data->id',
                ),
                array(
                    'name' => 'nombre',
                    'filter' => false
                ),
                array(
                    'name' =>'descripcion',
                    'filter' => false
                ),
                array(
                    'name' => 'tipo_carta_id',
                    'value' => 'isset($data->tipoCarta) ? $data->tipoCarta : null',
                    'filter' => CHtml::listData(TipoCarta::model()->findAll(), 'id', TipoCarta::representingColumn()),
                ),
                array(
                    'name' => 'edad',
                    'value' => 'isset($data->cartaAlimentoses)? CartaAlimentos::model()->de_edad_id($data->id) : null',
                    'filter' => false,
                ),
                array(
                    'class' => 'bootstrap.widgets.TbButtonColumn',
                    'template' => '{alimentos}',
                    'buttons' => array(
                        'alimentos' => array(
                            'label' => '<button class="btn btn-warning"><i class=" icon-search" ></i></button>',
                            'options' => array(
                                "title" => Yii::t('AweCrud.app', 'Ver Composición'),
                                'id' => '$data->id',
                            ),
                            'click' => 'js: function(e) { e.preventDefault();loadGrafica($(this).attr("id"));}',
                        ),
                    ),
                ),
            ),
        ));
        ?>
    </div>
</div>
<?php $this->endWidget(); ?>
